package com.ccsoft.leetcode.service;

import org.springframework.stereotype.Service;

import java.util.Iterator;

/**
 * 2021年11月5日 11:08:53 chanchaw
 * 26. 删除有序数组的重复项
 * 返回新数组的长度
 */
@Service
public class RemoveDuplicate {
    public int removeDuplicates(int[] nums) {
        int len = nums.length;
        if( len == 0 ) return 0;
        int val = 1;
        int walker = 1;
        while(walker < len){
            if(nums[walker] != nums[walker - 1]){
                nums[val] = nums[walker];
                val++;
            }
            walker++;
        }
        return val;
    }
}
